import matplotlib.pyplot as plt
import numpy as np
import os

def ACT():
    x_data = ['MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF']
    ind = np.arange(len(x_data))
    y_data1 = [78.16473812793275, 64.07344139974316, 65.27199211795624, 61.028119465018236, 64.91794195617985, 64.94438366560016, 64.70153992707635, 54.775239063167234, 64.66357349516872, 59.852441541925, 52.730377152318624, 52.730377152318624]
    y_data2 = [78.95991847826087, 64.60053120849933, 65.63974025974026, 61.24474936992439, 65.22228033472804, 65.22466614296937, 65.10067462376752, 55.54273237679351, 65.04434011476265, 60.086398131932285, 53.18444523724581, 53.18444523724581]
    w = 0.2
    ax = plt.subplot(111)
    a = ax.bar(ind,y_data1,width=0.2,align='center',color='red')
    b = ax.bar(ind+w,y_data2,width=0.2,align='center', color='lightseagreen')
    ax.set_xticks(ind+w)
    ax.set_xticklabels( ('MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF') )
    plt.legend((a,b),('ave ACT','worst ACT'))
    plt.autoscale(tight=True)
    plt.title('The average/worst ACT')
    plt.tight_layout()
    graph_path = os.path.dirname(os.path.abspath(__file__)) + '/graph/'
    if not os.path.isdir(graph_path):
        os.makedirs(graph_path)
    file_name = graph_path + __file__.split('/')[-1].split('.')[0]
    plt.savefig(f"{file_name}.pdf", bbox_inches='tight')
    plt.close()


if __name__ == '__main__':
    ACT()